<template>
  <div class="login">
    <h2>校园活动管理系统登录</h2>
    <form @submit.prevent="login">
      <div>
        <label>用户名:</label>
        <input v-model="username" type="text" required>
      </div>
      <div>
        <label>密码:</label>
        <input v-model="password" type="password" required>
      </div>
      <button type="submit">登录</button>
    </form>
  </div>
</template>

<script>
export default {
  data() {
    return {
      username: '',
      password: ''
    }
  },
  methods: {
    login() {
      // 模拟登录逻辑
      const role = this.username === 'admin' ? 'admin' : 'student'
      const user = { username: this.username, role }
      
      localStorage.setItem('user', JSON.stringify(user))
      this.$router.push('/home')
    }
  }
}
</script>

<style scoped>
.login {
  max-width: 400px;
  margin: 0 auto;
  padding: 20px;
}
form div {
  margin-bottom: 15px;
}
label {
  display: block;
  margin-bottom: 5px;
}
input {
  width: 100%;
  padding: 8px;
  box-sizing: border-box;
}
button {
  padding: 10px 15px;
  background: #42b983;
  color: white;
  border: none;
  cursor: pointer;
}
</style>